package com.lh.job.controller;

import com.lh.common.utils.PageUtils;
import com.lh.common.utils.Result;
import com.lh.job.entity.ScheduleJobLogEntity;
import com.lh.job.service.ScheduleJobLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 定时任务日志
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/sys/job/scheduleLog")
public class ScheduleJobLogController {
	@Autowired
	private ScheduleJobLogService scheduleJobLogService;

	/**
	 * 定时任务日志列表
	 */
	@RequestMapping(value = "/list",method = RequestMethod.GET)
	@RequiresPermissions("sys:schedule:log")
	public Result<PageUtils<ScheduleJobLogEntity>> list(@RequestParam Map<String, Object> params){
		PageUtils page = scheduleJobLogService.queryPage(params);

		return Result.ok(page);
	}

	/**
	 * 定时任务日志信息
	 */
	@RequestMapping(value = "/info/{logId}",method = RequestMethod.GET)
	public Result<ScheduleJobLogEntity> info(@PathVariable("logId") Long logId){
		ScheduleJobLogEntity log = scheduleJobLogService.getById(logId);

		return Result.ok(log);
	}
}
